package Beans.EJB_Refereces;



import Entities.RoomStatusEntity;

import javax.ejb.*;
import javax.persistence.PersistenceContext;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.annotation.Resource;
import java.util.List;


/**
 * Created by IntelliJ IDEA.
 * User: mchebanenko
 * Date: 4-Jan-2011
 * Time: 4:12:38 PM
 * To change this template use File | Settings | File Templates.
 */
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class RoomStyleRefBean implements IRoomStyleRef {

    public RoomStyleRefBean() {}

    @PersistenceContext(unitName="Hostel_persistence")
    private EntityManager entityManager;

    @Resource
    private SessionContext context;


    public List getRoomStyles (){
        Query qr = entityManager.createQuery("select distinct s.style_id, s.style_name, s.desc_tag from RoomEntity t , RoomStyleEntity s where t.style_id = s.style_id") ;
        return qr.getResultList();
    }


    public List getRoomCount (){
        Query qr = entityManager.createQuery("select distinct t.rooms_Qty from RoomEntity t") ;
        return qr.getResultList();
    }

    public List getRoomPlaces (){
        Query qr = entityManager.createQuery("select distinct t.places from RoomEntity t") ;
        return qr.getResultList();
    }

    public List getRoomStatusRef (){
        Query qr = entityManager.createQuery("select distinct t.status_id, t.status_name, t.status_desc from RoomStatusEntity t") ;
        return qr.getResultList();
    }



}
